#pragma once
#include "Utility.h"
#include <string>

namespace bs
{
	class InputSniffer
	{
	public:
		InputSniffer(HWND hwnd);
		~InputSniffer();

		void Sniff(const MSG& msg);
		void ClearBuffer();

		bool IsLBtnDown() const { return this->lBtnDown; }
		bool IsRBtnDown() const { return this->rBtnDown; }
		bool IsMBtnDown() const { return this->mBtnDown; }
		bool IsLBtnClk() const { return this->lBtnClk; }
		bool IsRBtnClk() const { return this->rBtnClk; }
		bool IsMBtnClk() const { return this->mBtnClk; }

		inline bool IsKeyDown(int keyCode) const { return this->keyStatus[keyCode]; }

		inline const Point& GetCursorScreenPos();
		const Point& GetCursorWinPos() const { return this->cursorWinPos; }

		std::string DumpInput();

	protected:
		enum
		{
			MAX_KEY_SIZE = 256
		};

		HWND hwnd;

		bool keyStatus[MAX_KEY_SIZE];
		
		bool lBtnDown;
		bool rBtnDown;
		bool mBtnDown;
		bool lBtnClk;
		bool rBtnClk;
		bool mBtnClk;

		Point cursorScrPos;
		Point cursorWinPos;
	};

}
